home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / grep / grep.lzh / dfa.h < prev    next >
C/C++ Source or Header  |  1989-03-02  |  22KB  |  556 lines

  1. /* dfa.h - declarations for GNU deterministic regexp compiler
  2.    Copyright (C) 1988 Free Software Foundation, Inc.
  3.                       Written June, 1988 by Mike Haertel
  4.  
  5.                NO WARRANTY
  6.  
  7.   BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
  8. NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
  9. WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
  10. RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
  11. WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  12. BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  13. FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
  14. AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
  15. DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
  16. CORRECTION.
  17.  
  18.  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
  19. STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
  20. WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
  21. LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
  22. OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
  23. USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
  24. DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
  25. A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
  26. PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
  27. DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
  28.  
  29.         GENERAL PUBLIC LICENSE TO COPY
  30.  
  31.   1. You may copy and distribute verbatim copies of this source file
  32. as you receive it, in any medium, provided that you conspicuously and
  33. appropriately publish on each copy a valid copyright notice "Copyright
  34.  (C) 1988 Free Software Foundation, Inc."; and include following the
  35. copyright notice a verbatim copy of the above disclaimer of warranty
  36. and of this License.  You may charge a distribution fee for the
  37. physical act of transferring a copy.
  38.  
  39.   2. You may modify your copy or copies of this source file or
  40. any portion of it, and copy and distribute such modifications under
  41. the terms of Paragraph 1 above, provided that you also do the following:
  42.  
  43.     a) cause the modified files to carry prominent notices stating
  44.     that you changed the files and the date of any change; and
  45.  
  46.     b) cause the whole of any work that you distribute or publish,
  47.     that in whole or in part contains or is a derivative of this
  48.     program or any part thereof, to be licensed at no charge to all
  49.     third parties on terms identical to those contained in this
  50.     License Agreement (except that you may choose to grant more extensive
  51.     warranty protection to some or all third parties, at your option).
  52.  
  53.     c) You may charge a distribution fee for the physical act of
  54.     transferring a copy, and you may at your option offer warranty
  55.     protection in exchange for a fee.
  56.  
  57. Mere aggregation of another unrelated program with this program (or its
  58. derivative) on a volume of a storage or distribution medium does not bring
  59. the other program under the scope of these terms.
  60.  
  61.   3. You may copy and distribute this program or any portion of it in
  62. compiled, executable or object code form under the terms of Paragraphs
  63. 1 and 2 above provided that you do the following:
  64.  
  65.     a) accompany it with the complete corresponding machine-readable
  66.     source code, which must be distributed under the terms of
  67.     Paragraphs 1 and 2 above; or,
  68.  
  69.     b) accompany it with a written offer, valid for at least three
  70.     years, to give any third party free (except for a nominal
  71.     shipping charge) a complete machine-readable copy of the
  72.     corresponding source code, to be distributed under the terms of
  73.     Paragraphs 1 and 2 above; or,
  74.  
  75.     c) accompany it with the information you received as to where the
  76.     corresponding source code may be obtained.  (This alternative is
  77.     allowed only for noncommercial distribution and only if you
  78.     received the program in object code or executable form alone.)
  79.  
  80. For an executable file, complete source code means all the source code for
  81. all modules it contains; but, as a special exception, it need not include
  82. source code for modules which are standard libraries that accompany the
  83. operating system on which the executable file runs.
  84.  
  85.   4. You may not copy, sublicense, distribute or transfer this program
  86. except as expressly provided under this License Agreement.  Any attempt
  87. otherwise to copy, sublicense, distribute or transfer this program is void and
  88. your rights to use the program under this License agreement shall be
  89. automatically terminated.  However, parties who have received computer
  90. software programs from you with this License Agreement will not have
  91. their licenses terminated so long as such parties remain in full compliance.
  92.  
  93.   5. If you wish to incorporate parts of this program into other free
  94. programs whose distribution conditions are different, write to the Free
  95. Software Foundation at 675 Mass Ave, Cambridge, MA 02139.  We have not yet
  96. worked out a simple rule that can be stated here, but we will often permit
  97. this.  We will be guided by the two goals of preserving the free status of
  98. all derivatives our free software and of promoting the sharing and reuse of
  99. software.
  100.  
  101.  
  102. In other words, you are welcome to use, share and improve this program.
  103. You are forbidden to forbid anyone else to use, share and improve
  104. what you give them.   Help stamp out software-hoarding!  */
  105.  
  106.  
  107. #ifdef USG
  108. #include <string.h>
  109. extern char *index();
  110. #else
  111. #include <strings.h>
  112. #ifdef ATARI_ST
  113. extern char *strchr(), *strrchr();
  114. #else
  115. extern char *strchr(), *strrchr(), *memcpy();
  116. #endif
  117. #endif
  118.  
  119. #ifdef __STDC__
  120.  
  121. /* Missing include files for GNU C. */
  122. /* #include <stdlib.h> */
  123. typedef int size_t;
  124. extern void *calloc(int, size_t);
  125. extern void *malloc(size_t);
  126. extern void *realloc(void *, size_t);
  127. extern void free(void *);
  128.  
  129. extern char *bcopy(), *bzero();
  130.  
  131. #ifdef SOMEDAY
  132. #define ISALNUM(c) isalnum(c)
  133. #define ISALPHA(c) isalpha(c)
  134. #else
  135. #define ISALNUM(c) (isascii(c) && isalnum(c))
  136. #define ISALPHA(c) (isascii(c) && isalpha(c))
  137. #endif
  138.  
  139. #else /* ! __STDC__ */
  140.  
  141. #define const
  142. typedef int size_t;
  143. extern char *calloc(), *malloc(), *realloc();
  144. extern void free();
  145.  
  146. extern char *bcopy(), *bzero();
  147.  
  148. #define ISALNUM(c) (isascii(c) && isalnum(c))
  149. #define ISALPHA(c) (isascii(c) && isalpha(c))
  150.  
  151. #endif /* ! __STDC__ */
  152.  
  153. /* 1 means plain parentheses serve as grouping, and backslash
  154.      parentheses are needed for literal searching.
  155.    0 means backslash-parentheses are grouping, and plain parentheses
  156.      are for literal searching.  */
  157. #define RE_NO_BK_PARENS 1
  158.  
  159. /* 1 means plain | serves as the "or"-operator, and \| is a literal.
  160.    0 means \| serves as the "or"-operator, and | is a literal.  */
  161. #define RE_NO_BK_VBAR 2
  162.  
  163. /* 0 means plain + or ? serves as an operator, and \+, \? are literals.
  164.    1 means \+, \? are operators and plain +, ? are literals.  */
  165. #define RE_BK_PLUS_QM 4
  166.  
  167. /* 1 means | binds tighter than ^ or $.
  168.    0 means the contrary.  */
  169. #define RE_TIGHT_VBAR 8
  170.  
  171. /* 1 means treat \n as an _OR operator
  172.    0 means treat it as a normal character */
  173. #define RE_NEWLINE_OR 16
  174.  
  175. /* 0 means that a special characters (such as *, ^, and $) always have
  176.      their special meaning regardless of the surrounding context.
  177.    1 means that special characters may act as normal characters in some
  178.      contexts.  Specifically, this applies to:
  179.     ^ - only special at the beginning, or after ( or |
  180.     $ - only special at the end, or before ) or |
  181.     *, +, ? - only special when not after the beginning, (, or | */
  182. #define RE_CONTEXT_INDEP_OPS 32
  183.  
  184. /* Now define combinations of bits for the standard possibilities.  */
  185. #define RE_SYNTAX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR | RE_CONTEXT_INDEP_OPS)
  186. #define RE_SYNTAX_EGREP (RE_SYNTAX_AWK | RE_NEWLINE_OR)
  187. #define RE_SYNTAX_GREP (RE_BK_PLUS_QM | RE_NEWLINE_OR)
  188. #define RE_SYNTAX_EMACS 0
  189.  
  190. /* The NULL pointer. */
  191. #define NULL 0
  192.  
  193. /* Number of bits in an unsigned char. */
  194. #define CHARBITS 8
  195.  
  196. /* First integer value that is greater than any character code. */
  197. #define _NOTCHAR (1 << CHARBITS)
  198.  
  199. /* INTBITS need not be exact, just a lower bound. */
  200. #define INTBITS (CHARBITS * sizeof (int))
  201.  
  202. /* Number o